    $(function() {
        $('section').on('click', "a", function() {
            let list = getData();
            let index = $(this).attr('id');
            list.splice(index, 1);
            sevaData(list);
            load(list);
        })

        let title = $('#title');
        title.on('keyup', function(e) {
            //console.log($(this).val());
            if (e.keyCode == 13 && $(this).val() != "") {
                let list = getData();
                list.push({
                    title: $(this).val(),
                    done: false
                });
                sevaData(list);
                load(list);
                $(this).val("");
            }
        })

        let todolist = $('#todolist');
        let donelist = $('#donelist');

        function load(list) {
            todolist.empty();
            donelist.empty();
            let todo = 0;
            let done = 0;
            $.each(list, function(i, n) {
                if (n.done) {
                    done++;
                    donelist.prepend("<li><input type='checkbox' checked='checked'> <p>" + n.title + "</p> <a href='javascript:;' id=" + i + " ></a></li>");
                } else {
                    todo++;
                    todolist.prepend("<li><input type='checkbox' > <p>" + n.title + "</p> <a href='javascript:;' id=" + i + " ></a></li>");
                }
            })
            $("#todocount").text(todo);
            $("#donecount").text(done);
        }
        load(getData());

        function sevaData(list) {
            localStorage.setItem('list', JSON.stringify(list));
        }

        function getData() {
            let list = localStorage.getItem("list");
            if (list == null)
                return [];
            else
                return JSON.parse(list);
        }

        $('section').on('click', "input", function() {
            let list = getData();
            let index = $(this).siblings('a').attr('id');
            list[index].done = $(this).prop('checked');

            console.log(list);
            sevaData(list);
            load(list);
        })
    })